/*
 * @Description: 饼状图
 * @Author: Zzt
 * @Date: 2022-11-10 09:19:30
 * @LastEditTime: 2022-11-16 18:46:49
 */

import { useEcharts } from '@/hooks/useEcharts';
import * as echarts from 'echarts';
import { useMemo } from 'react';

interface IPieCharts {
  color?: any;
  data: any;
}
const PieCharts = (props: IPieCharts) => {
  const { color, data } = props;
  console.log('传来了data', data);
  const option: echarts.EChartsOption = {
    // color,
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      left: 'left'
    },
    series: [
      {
        type: 'pie',
        radius: '50%',
        data
      }
    ]
  };

  const [echartsRef] = useEcharts(option);

  // option && myChart.setOption(option);
  return (
    <>
      {useMemo(
        () => (
          <div style={{ height: '300px' }} ref={echartsRef}></div>
        ),
        [echartsRef]
      )}
    </>
  );
};
export default PieCharts;
